from __future__ import division

def factor(arr1, arr2, n):
	arr = [0] * len(arr1)
	for i in range(n, len(arr1)):
		arr[i] = arr1[i] * arr2[i-1]
	b = -2 * sum(arr[n:len(arr)])

	for i in range(n, len(arr2)):
		arr[i] = arr1[i]*arr1[i] + arr2[i-1]*arr2[i-1]
	c = sum(arr[n:len(arr)])
	return b/c

def burg(arr, n):
	a = [[0]*(n+1)]*(n+1)
	ef = [[0]*len(arr)]*n
	eb = [[0]*len(arr)]*n
	ef[0] = arr[:]
	eb[0] = arr[:]

	for i in range(1, 1+n):
		if i==1:
			a[1][1] = factor(ef[0], eb[0], 1)
		else:
			for j in range():
				pass
	return result

def burg3(arr):
	ef0 = [0] * len(arr)
	eb0 = [0] * len(arr)
	ef1 = [0] * len(arr)
	eb1 = [0] * len(arr)
	ef2 = [0] * len(arr)
	eb2 = [0] * len(arr)

	for i in range(1, len(arr)):
		ef0[i] = arr[i]
	for i in range(0, len(arr)-1):
		eb0[i] = arr[i]
	a11 = factor(ef0,eb0,1)

	for i in range(2, len(arr)):
		ef1[i] = ef0[i] + a11 * eb0[i-1]
	for i in range(1, len(arr)-1):
		eb1[i] = eb0[i-1] + a11 * ef0[i]
	a22 = factor(ef1,eb1,2)
	
	for i in range(3, len(arr)):
		ef2[i] = ef1[i] + a22 * eb1[i-1]
	for i in range(2, len(arr)-1):
		eb2[i] = eb1[i-1] + a22 * ef1[i]
	a33 = factor(ef2,eb2,3)

	a21 = a11 + a22 * a11
	a31 = a21 + a33 * a22
	a32 = a22 + a33 * a21

	return a31, a32, a33

if __name__ == '__main__':
	print(burg3([1,1,1,1,3,1,1,1]))